<template>
  <div>
    <el-backtop :right="100" :bottom="200" :visibility-height="10" />
    <el-space wrap style="margin-bottom:10px">
      <el-input v-model="text" placeholder="请输入管理员ID" class="input" clearable />
      <el-button type="primary" :icon="Search" @click="adminLog">查找</el-button>
    </el-space>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column prop="id" label="日志ID" />
      <el-table-column prop="adminId" label="管理员ID" />
      <el-table-column prop="requestId" label="请求ID" />
      <el-table-column prop="group" label="Apl分组" />
      <el-table-column prop="method" label="Apl方法" />
      <el-table-column prop="gmtCreate" label="操作时间">
        <template #default="scope">{{timestampToD(scope.row.gmtCreate)}}</template>
      </el-table-column>
    </el-table>
    <dome v-bind="domes" @limits="limits" @pages="pages" />
  </div>
</template>
<script>
import { post } from "@/util/http";
// import dome from "@/components/Dome.vue";
import dome from "@/components/DomeAndTop.vue";
import timestampToD from "../../../timeformat/formatD";
import { Search } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";
export default {
  components: {
    dome,
  },
  data() {
    return {
      Search,
      text: "",
      tableData: [],
      domes: {
        limit: 10,
        page: 10,
        total: 10,
      },
    };
  },
  created() {
    this.adminLog();
  },
  methods: {
    timestampToD,
    adminLog() {
      let logdata = {
        _gp: "admin.log",
        _mt: "list",
        // id: this.id,
        targetAdminId: this.text,
        page: this.domes.page,
        limit: this.domes.limit,
      };
      post(logdata)
        .then((res) => {
          if (200 == res.data.errno) {
            this.tableData = res.data.data.items;
            this.domes.total = res.data.data.total;
          } else {
            ElMessage.warning(res.data.errmsg);
          }
        })
        .catch((err) => {
          ElMessage.warning(err.data.errmsg);
        });
    },
    limits(e) {
      this.domes.limit = e;
      this.$nextTick(() => {
        this.adminLog();
      });
    },
    pages(e) {
      this.domes.page = e;
      this.$nextTick(() => {
        this.adminLog();
      });
    },
  },
};
</script>
<style lang="less" scoped>
.input {
  width: 240px;
}
</style>